package me.xingyannian.zhaopin.repository;

import me.xingyannian.zhaopin.entity.ChangCi;
import me.xingyannian.zhaopin.entity.Job;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface JobRepository extends JpaRepository<Job, Long> , JpaSpecificationExecutor<Job> {
  Page<Job> findAllByChangCi(ChangCi changCi, Pageable pageable);
  @Query("select distinct j.subject from Job j where j.changCi = :#{#changCi}")
  List<String> findDistinctSubjectByChangCi(ChangCi changCi);
  List<Job> findAllByChangCiAndSubjectAndStage(ChangCi changCi, String subject, String stage);
  @Query("select distinct j.region from Job j where j.changCi = :#{#changCi}")
  List<String> findDistinctRegionByChangCi(ChangCi changCi);

  List<Job> findAllByChangCiAndRegionAndDegree(ChangCi changCi, String region, String degree);
}